home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / emacs16d.zip / _CASE.MIN < prev    next >
Text File  |  1991-07-19  |  4KB  |  192 lines

  1.  
  2.  
  3.  
  4. Name:F:capitalize-word
  5. Capitalize word(s) before/after point.
  6. [*]    
  7. #(Fxlat-words,capitalize,(arg1))
  8. [*]
  9.  
  10.  
  11. Name:F:downcase-region
  12. Change the entire region to lowercase.
  13. [*]#(Fxlat-region,#(Fmark),Fxlat-lower)[*]
  14.  
  15.  
  16. Name:F:downcase-word
  17. Lowercase word(s) before/after point.
  18. [*]    
  19. #(Fxlat-words,downcase,(arg1))
  20. [*]
  21.  
  22.  
  23. Name:F:upcase-region
  24. Uppercase the region.
  25. [*]#(Fxlat-region,#(Fmark),Fxlat-upper)[*]
  26.  
  27.  
  28. Name:F:upcase-word
  29. Uppercase word(s) before/after point.
  30. [*]    
  31. #(Fxlat-words,upcase,(arg1))
  32. [*]
  33.  
  34.  
  35. Name:Fcapitalize-word-do
  36. Capitalize the word after point.
  37. [*]#(sp,+)
  38. #(Fxlat-region,>,Fxlat-upper)
  39. #(sp,>)
  40. #(Fxlat-region,},Fxlat-lower)
  41. #(sp,})
  42. [*]
  43.  
  44.  
  45. Name:Fcase
  46. Args:(a01,a02,a03,a04,a05,a06,a07,a08,a09,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20)
  47. [wjm 4/13/90]  The only argument that should be unprotected is the one
  48. instance of arg2.
  49. [wjm 4/30/90] Allow up to 18 cases, plus (mandatory) default.
  50. ................
  51. (lots more explanation than code.  This sucker's tricky)
  52.  
  53. If you look at the second ==, #(==,arg1,arg2,(...)), you might expect
  54. that if arg1 == arg2 then (...) gets returned.  However, Fcase is called
  55. like this:
  56.  
  57. #(Fcase,arg1,
  58.     (new,(
  59.         stuff to do if arg1 = new.
  60.     )),
  61.     (forward,(
  62.         stuff to do if arg1 = forward.
  63.     )),
  64.     (backward,(
  65.         stuff to do if arg1 = backward.
  66.     )),
  67.     (
  68.         stuff to do if arg1 isn't any of the above
  69.     )
  70. )
  71.  
  72. As you can see, arg2 has an unprotected comma in it, so that when the 
  73. second == gets executed, it looks like this:
  74.  
  75. #(==,arg1,new,(yes),(no))
  76.  
  77. Tests:
  78.  
  79. #(Fcase,a,(a,yes a),(b,yes b))
  80. #(Fcase,b,(a,yes a),(b,yes b))        [doesn't work]
  81. #(Fcase,b,(a,yes a),(b,yes b),(yes c))
  82. #(Fcase,c,(a,yes a),(b,yes b),(yes c))
  83. Ok, the code starts here:
  84. [*]#(==,(a03),,(a02),(
  85.     #(==,(a02),,,(
  86.         #(==,(a01),a02,(
  87.             #(SELF,(a01),(a03),(a04),(a05),(a06),(a07),(a08),(a09),(a10),(a11),(a12),(a13),(a14),(a15),(a16),(a17),(a18),(a19),(a20))
  88.         ))
  89.     ))
  90. ))
  91. [*]
  92.  
  93.  
  94. Name:Fcase-fold
  95. Given a string in old-search and old-replace and a match in temp, return the
  96. replacement string.
  97.   arg1 = ASCII value of char from old-search.
  98.   arg2 = ASCII value of char from old-replace.
  99.   arg3 = ASCII value of char from temp.
  100. [*]#(==,arg1,,,(
  101.     #(Fisupper,arg2,(
  102.         ##(bc,arg2,d,a)
  103.     ),(
  104.         #(Fisupper,arg1,(
  105.             ##(bc,arg2,d,a)
  106.         ),(
  107.             #(Fand,(Fisupper,arg3),(Fisupper,arg2),(
  108.                 ##(bc,##(--,arg2,32),d,a)
  109.             ),(
  110.                 ##(bc,arg2,d,a)
  111.             ))
  112.         ))
  113.     ))
  114. ))
  115. #(==,##(old-search),,(
  116.     #(rs,old-search)
  117.     #(rs,old-replace)
  118. ),(
  119.     #(SELF,##(bc,##(go,old-search)),##(bc,##(go,old-replace)),##(bc,##(go,temp)))
  120. ))[*]
  121.  
  122.  
  123. Name:Fdowncase-word-do
  124. Lowercase the word after point.
  125. [*]#(sp,+)
  126. #(Fxlat-region,},Fxlat-lower)
  127. #(sp,})
  128. [*]
  129.  
  130.  
  131. Name:Fupcase-word-do
  132. Uppercase the word after point.
  133. [*]#(sp,+)
  134. #(Fxlat-region,},Fxlat-upper)
  135. #(sp,})
  136. [*]
  137.  
  138.  
  139. Name:Fxlat-lower
  140. [*]    
  141.  !"#$%&'()*+,-./0123456789:;<=>?@abcdefghijklmnopqrstuvwxyz[\]^_`abcdefghijklmnopqrstuvwxyz[*]
  142.  
  143.  
  144. Name:Fxlat-region
  145. Translate the region according to the mark in arg1, and the string in arg2.
  146. Note: cannot be called with a local mark (0..9).
  147. [*]#(pm,2)
  148. #(sm,0,arg1)
  149. #(==,
  150.     #(mb,0,no,yes)
  151.     #(ds,temp,##(si,arg2,##(rm,0)))
  152.     #(==,##(temp),,,(
  153.         #(dm,0)
  154.         #(is,##(go,temp))
  155.         #(sm,0,<)
  156.         #(is,##(gs,temp))
  157.     ))
  158. ,yes,(
  159.         #(sm,1,.)
  160.         #(sp,0)
  161.         #(sm,0,1)
  162. ))
  163. #(sm,arg1,0)
  164. #(pm)[*]
  165.  
  166.  
  167. Name:Fxlat-upper
  168. [*]    
  169.  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ[*]
  170.  
  171.  
  172. Name:Fxlat-words
  173. Translate words, accepting numerical arguments like GNU Emacs.
  174. BUG: in case of a negative argument, if there are too few words
  175. between [ and point, also words to the right of point might be translated.
  176. [*]
  177. #(==,(arg2),,(
  178.         #(F(arg1)-word-do)
  179.     ),(
  180.         #(==,(arg2),-,(
  181.                 #(sp,-{)#(ds,count,1)
  182.             ),(
  183.                 #(g?,0,(arg2),(
  184.                     #(ds,count,##(--,0,(arg2)))
  185.                     #(sp,#(Floop,-{,##(count)))
  186.                 ),(
  187.                     #(ds,count,(arg2))
  188.                 ))
  189.             ))
  190.         #(Floop,(#(F(arg1)-word-do)),##(count))
  191.     ))
  192. [*]